# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=nvui
pkgver=0.3.1
pkgrel=7
pkgdesc="A modern frontend for Neovim"
url="https://github.com/rohit-px2/nvui"
# riscv64: blocked by neovim
arch="all !riscv64"
license="MIT"
depends="
	hicolor-icon-theme
	neovim
	"
makedepends="
	boost-dev
	catch2
	cmake
	fmt-dev
	msgpack-cxx-dev
	ninja
	qt5-qtbase-dev
	qt5-qtsvg-dev
	"
source="https://github.com/rohit-px2/nvui/archive/v$pkgver/nvui-$pkgver.tar.gz
	msgpack-cxx-6.patch
	fhs-paths.patch
	use-sane-animation-time.patch
	nvui.sh
	$pkgname.desktop
	"

build() {
	local crossopts=
	if [ "$CBUILD" != "$CHOST" ]; then
		crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -G Ninja -B build \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		$crossopts .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE LANG=C ctest
}

package() {
	install -D -m755 build/nvui -t "$pkgdir"/usr/libexec/
	install -D -m755 "$srcdir"/nvui.sh "$pkgdir"/usr/bin/nvui

	install -d "$pkgdir"/usr/share/$pkgname
	cp -r vim "$pkgdir"/usr/share/$pkgname/

	install -D -m644 "$srcdir"/$pkgname.desktop -t "$pkgdir"/usr/share/applications/
	install -D -m644 assets/appicon.png "$pkgdir"/usr/share/icons/hicolor/128x128/apps/$pkgname.png
}

sha512sums="
9ee10ca52298b85fe3a838e1ed12f7a2e674c08d7e0013426cc9e8cb83dfc6559b0afbad2ea3b80ba325de3b81f737f0c0c9c85d2e4a44f9b4f27cc3743992b7  nvui-0.3.1.tar.gz
c12b260fc85fa55ce1441d678da48714df18a850c9dee3b22c0e98aff16c34843b83c340665771b22a0eb8c7533ed068395573392927ec39c1fdc2e193c80867  msgpack-cxx-6.patch
6e589429ba8149a1e31be263f6ee276bce4ca000e31f2b110d6dbca6d5f655afb3b042e0f2efa59ea2f4c604adb1e78244a6d4dc5efaa795c78bc855b365f30e  fhs-paths.patch
c3223dd93d45d7449b6cb075dc6b033bb1301b5316408d7a446f4df6873381586d81d51b8856a2e84bb698993e1d80f2682633f692a2eda2fd23bb45ae074d4b  use-sane-animation-time.patch
d781d307ad39d53f91660455fe0c6bed4698b9c70daca178652ba72d2326005dc47cfbb039c62ef97b165ae5be96e49c2e3e837f9674689b9717a336db65f7c2  nvui.sh
03c2ea47f3b7fb748978fbe4dc54d475db2258e6078061595f0da8fa02a4eba0610138f1b2c14d8aa6a25dc7299abb687f53a44d0a1eedd3da06587107679ecf  nvui.desktop
"
